<%
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="Connections/conDB.jsp" %>
<% int validaSession = 2; %>
<%@ include file="Connections/session.jsp" %>

<%
String Id_Almacen = (String) session.getAttribute("id_almac") == null ? (String) session.getAttribute("id_almac") : (String) session.getAttribute("id_almac");
//out.println("<br> ------"+Id_Almacen);
if (Id_Almacen==null) {
 	Id_Almacen = "0";
 }

int valMax = 0;
java.util.Calendar fechaHoy = java.util.Calendar.getInstance();
String fecha = fechaHoy.get(fechaHoy.DATE)+"/"+(fechaHoy.get(fechaHoy.MONTH)+1)+"/"+fechaHoy.get(fechaHoy.YEAR);

Driver DriverRs = (Driver)Class.forName(MM_conDB_DRIVER).newInstance();
Connection ConnRs = DriverManager.getConnection(MM_conDB_STRING,MM_conDB_USERNAME,MM_conDB_PASSWORD);

String query = "SELECT id_liber FROM liberacion ORDER BY id_liber DESC";
PreparedStatement StatementRs = ConnRs.prepareStatement(query);
ResultSet Rsquery = StatementRs.executeQuery();
if (Rsquery.next()) {
	valMax = Rsquery.getInt("id_liber");
}
%>

<html>
<head>
<title>CIMA v2 - Nueva Liberaci&oacute;n</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="miestilo.css" type="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="js/AnchorPosition.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/PopupWindow.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/date.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="js/CalendarPopup.js"></SCRIPT>
<script>
var cal1 = new CalendarPopup();
//-----
function enviaSubmit() {
		if (valida()) {
			document.form1.submit();
		}
	}
//-----
function valida() {
	var Doc = document.form1;
	missinginfo = "";
	if (Doc.fecha.value == "")     missinginfo += "\n     - Fecha";
	if (missinginfo != "") {
		missinginfo = "Favor de llenar el campo de fecha";
		alert(missinginfo);
		return false;
	}else{
		return true;
	}
}
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" background="images/fondo.jpg">
<br>
<center>
  <form name="form1" method="post" action="liberacion_querys.jsp">
    <table width="190" border="0" cellpadding="0" cellspacing="0">
      <tr align="center"> 
        <td class="titulos" colspan="3">Nueva Liberaci&oacute;n</td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta" height="20">N&uacute;mero</td>
        <td width="7">&nbsp;</td>
        <td>&nbsp;<%=valMax+1%>
		<input type="hidden" name="id_liber" value="<%=valMax+1%>">
		</td>
      </tr>
      <tr> 
        <td align="right" class="etiqueta">Fecha</td>
        <td>&nbsp;</td>
        <td> 
          <input type="text" name="fecha" class="textfields" size="18" onFocus="blur()" readonly value="<%=fecha%>" tabindex="-1">
          <img src="images/calendar2.gif" class="cursor" name="imgF" onClick="cal1.select(document.form1.fecha,'imgF','dd/MM/yyyy'); return false;" width="18" height="18"> 
        </td>
      </tr>
    </table>
<br>
    <table width="200" border="0" cellpadding="0" cellspacing="0">
      <tr> 
        <td align="center"> 
		<input type="hidden" name="id_almacen" value="<%=Id_Almacen%>">
		<a href="javascript:enviaSubmit()"><img src="images/bGuardar.gif" width="83" height="18" border="0"></a>&nbsp; 
        <a href="javascript:window.close()"><img src="images/bCerrar.gif" width="83" height="18" border="0"></a></td>
      </tr>
    </table>
</form>
</center>
</body>
<HEAD>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
</HEAD>
</html>
<%
Rsquery.close();
StatementRs.close();
ConnRs.close();
%>